﻿using System;
using System.Management;

namespace CSharp.Common.Machine
{
    public class MachineHelper
    {
        public static string GetCPUID()
        {
            string str = string.Empty;
            try
            {
                try
                {
                    ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
                    foreach (ManagementObject obj2 in searcher.Get())
                    {
                        str = obj2["ProcessorId"].ToString();
                    }
                    return str;
                }
                catch (Exception exception)
                {
                    throw new Exception(exception.ToString());
                }
            }
            finally
            {
            }
            return str;
        }

        public static int GetHardGUID()
        {
            uint num = 0;
            try
            {
                try
                {
                    ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
                    foreach (ManagementObject obj2 in searcher.Get())
                    {
                        num = Convert.ToUInt32(obj2["signature"].ToString());
                    }
                }
                catch (Exception exception)
                {
                    throw new Exception(exception.ToString());
                }
            }
            finally
            {
            }
            return int.Parse(num.ToString());
        }
    }
}

